package com.zero365.autobak;

import java.util.List;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;

import com.zero365.schedule.JobService;
import com.zero365.schedule.PageTrigger;
@Controller
public class PlanBackup {
	
	public static void main(String[] args) {
		System.out.println("当前路径:"+System.getProperty("user.dir"));
		String classpath = "beans.xml";
//		BeanFactory factory = new XmlBeanFactory(new ClassPathResource(classpath));
 

	    ApplicationContext factory = new ClassPathXmlApplicationContext("beans.xml");
//	    UserDao userDao = (UserDao)ctx.getBean("userDaoImpl");
//	    userDao.save();
	    JobService jobService = (JobService)factory.getBean("jobService");
	    
		List<PageTrigger> triggers = jobService.getTriggersInfo();
		System.out.println(triggers.size());
		for(PageTrigger tig:triggers){
			  
			System.out.print(tig.getName());
			System.out.print(" - "+tig.getGroup());
			System.out.print(" - "+tig.getExpression());
			System.out.print(" - "+tig.getStatus());
			System.out.print(" - "+tig.getClass());
			System.out.print(" - "+tig.getDesc()+"\n");
			//jobService.startNowJob(tig.getName(), tig.getGroup());
		}
	}
}
